package com.lc.mapper;

import com.lc.mode.Request;
import com.lc.mode.Response;

/**
 * @author liuc
 * @date 2021/5/5
 * @description 定义get,post,delete,put处理方法
 **/
public abstract class HttpServlet implements Servlet{

    public void service(Request request, Response response) {
        switch (request.getRequestType()){
            case GET: dpGet(request,response); break;
            case POST: doPost(request,response); break;
            case DELETE: doDelete(request,response); break;
            case PUT: doPut(request,response); break;
            default:break;
        }
    }

    /**
     * 处理get请求
     * @param request
     * @param response
     */
    protected abstract void dpGet(Request request, Response response);
    /**
     * 处理post请求
     * @param request
     * @param response
     */
    protected abstract void doPost(Request request, Response response);
    /**
     * 处理delete请求
     * @param request
     * @param response
     */
    protected abstract void doDelete(Request request, Response response);
    /**
     * 处理put请求
     * @param request
     * @param response
     */
    protected abstract void doPut(Request request, Response response);
}
